﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommonFunction
{
    public class OpenHelper : OpenInterface
    {
        public string OpenFile(string path)
        {
            try
            {
                System.Diagnostics.Process.Start(path);
                return null;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
            
        }

        public string OpenWebSite(string url)
        {
            try
            {
                Process.Start(url);
                return null;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
            
        }
    }

    interface OpenInterface
    {
        /// <summary>
        /// 输入网址，用默认浏览器打开该网址
        /// </summary>
        /// <param name="url"></param>
        string OpenWebSite(string url);

        /// <summary>
        /// 输入本地地址，打开文件或文件夹
        /// </summary>
        /// <param name="path"></param>
        string OpenFile(string path);
    }
}
